#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int number(int i, int n)
{
	int r = 1;
	int num = 0;
	for (num=1;num <= n;num++)
	{
		r *= i;
	}
	return r;
}
int pan(int i, int n)
{
	int c = 1;
	int m = i;
	int sum = 0;
	for (c;c <= n;c++)
	{
		sum = sum + number(m % 10, n);
		m /= 10;
	}
	if (sum == i)
	{
		return 0;
	}
	else
		return 1;
}
int main()
{
	int i = 1;
	for (i;i <= 10000;i++)
	{
		int j = i;
		int n = 0;
		while (j > 0)
		{
			j /=10;
			n++;
		}
		if (pan(i, n) == 0)
		{
			printf("%d ", i);
		}
	}
	return 0;
}
